#{extends 'main.html'/}
<script type="text/javascript">
   //user,dept初始值,放在最外面，让所有方法都能读取
    var groupicon = "/public/ligerUI/skins/icons/communication.gif";
    //var tag=${tag};
 
    var pVisualize = [{"describe":"完成低压区","id":6},{"describe":"完成高压线路","id":7},{"describe":"完成低压线路","id":8},{"describe":"完成接户线","id":9},{"describe":"完成户表改造","id":10},{"describe":"完成10KV线路","id":11}];
    	//$("#pVisualize").val();
 
    var queryform = $("#queryform");
    queryform.ligerForm({
        inputWidth: 180, labelWidth: 70, space: 10,
        fields: [
        { name: "ProductID", type: "hidden" },
        { display: "项目名称", name: "productName", newline: false, type: "text",height:30,
        	group: "工程形象建设信息查询", groupicon: groupicon}, 
        { display: "合同单位", name: "contractUnit", newline: false, height:30,
        		comboboxName: "CompanyName" }
        ]
    });
    
    var queryButton = null;
    queryButton = $("#queryButton").ligerButton(
        {
            click: function (){
                $(queryform).submit();
            },
            width: 50, text: '查询'
        }
    )

    $(queryform).bind("submit",function(){
    	var productName =$("#productName").val();
    	var contractUnit = $("#contractUnit").val();
    	var action = $(queryform).attr("action");
    	$.getJSON(action,{productName:productName,contractUnit:contractUnit},function(data){
    		grid.loadData(data);
    	});
    })
    
    
    $(f_initGrid);
    
    function f_initGrid()
    { 
        grid = manager = $("#maingrid").ligerGrid({
            columns: [
                { display: 'id', name: "id", width: 50,  hide: false},
                { display: '描述', name: 'pvDescribe', width: 200, type: 'string', align:'left',
                	editor: { type: 'select', data: pVisualize, valueColumnName: 'id'}
                },
                { display: '数值', name: 'quantity',width: 100, type: 'string', align:'left',
                	editor: { type: 'text' }
                },
                //{ display: '单位', name: 'quantity', width: 40, type: 'string', align:'left'},
                { display: '所属月份', name: 'belongDate',width: 100, type: 'date',format: 'yyyy-MM-dd', align:'left',
                	editor: { type: 'date' }
                },
                { display: '备注', name: 'remark',width: 100, type: 'text', align:'left',
                	editor: { type: 'text'}
                },
                { display: '操作', isSort: false, width: 120, render: function (rowdata, rowindex, value)
                    {
                        var h = "";
                        var id=rowdata.id;
                        var data = JSON2.stringify(rowdata);
                        if (!rowdata._editing)
                        {
                            h += "<a href='javascript:modityRow(" + rowindex + ")'>修改</a> ";
                            h += "<a href='javascript:deleteRow(" + id + ")'>删除</a> "; 
                        }
                        else
                        {
                            h += "<a href='javascript:submitRow(" + data + ")'>提交</a> ";
                            h += "<a href='javascript:cancelEdit(" + rowindex + ")'>取消</a> "; 
                        }
                        return h;
                    }
                 }
            ],
            
            onSelectRow: function (rowdata, rowindex)
            {
                $("#txtrowindex").val(rowindex);
            },
            enabledEdit: true,
            clickToEdit:false,
            isScroll: false,
            width: '100%',
            frozen:true,
            url: "/pvReport/json",
			method: "GET",                
            title:"工程形象建设统计表",
            pageSize: 30,
            height:425,
			rownumbers:false,
            toolbar: { items: [
                    { text: '添加', click: addRow, icon: 'add' },
                    { line: true }
                ] } 
        });
    }
    
    function modityRow(rowid){
    	manager.beginEdit(rowid);
    }
    function deleteRow(id){
    	alert(id);
    }
    function submitRow(data){
    	debugger;
    	alert(data);
    }
    function cancelEdit(rowData){}
    function addRow(){
    	manager.addEditRow();
    }

        
</script>
<input type="hidden" id="pVisualize" value="${pVisualizes}"/>
<div id="query" style="display: block;">
    <form id = "queryform" method="post" action="/projects/serach"></form>
    <div id="queryButton"></div>
</div>
<div id="maingrid" style="margin-top:10px">
</div>


